﻿CREATE TABLE [dbo].[EntityFBTypes] (
    [ID]       INT IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
    [EntityID] INT NOT NULL,
    [FBTypeID] INT NOT NULL,
    CONSTRAINT [PK__EntityFB__3214EC272EDAF651] PRIMARY KEY CLUSTERED ([ID] ASC),
    CONSTRAINT [FK__EntityFBT__Entit__30C33EC3] FOREIGN KEY ([EntityID]) REFERENCES [dbo].[Entities] ([EntityID]),
    CONSTRAINT [FK_EntityFBTypes_FreebaseTypes] FOREIGN KEY ([FBTypeID]) REFERENCES [dbo].[FreebaseTypes] ([id]) ON DELETE CASCADE ON UPDATE CASCADE
);


GO
CREATE NONCLUSTERED INDEX [ix_EntityID_FBTypeID]
    ON [dbo].[EntityFBTypes]([EntityID] ASC)
    INCLUDE([FBTypeID]);


GO
CREATE NONCLUSTERED INDEX [ix_FBTypeID_EntityID]
    ON [dbo].[EntityFBTypes]([FBTypeID] ASC)
    INCLUDE([EntityID]);

